package com.blog.SystemMsg;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author 任浩
 * @version 1.0
 */

@Component
public class SystemMsgProducer {

    //得到rabbitmq的使用类
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 生产消息的方法。
     */
    public void producer(String msg){
        rabbitTemplate.convertAndSend("exchange","info",msg);
    }

    /**
     * 生产搜索消息的方法。
     */
    public void searchProducer(String msg){
        rabbitTemplate.convertAndSend("searchExchange","search",msg);
    }

    /**
     * 生产删除es帖子的方法。
     * @param msg
     */
    public void searchDeleteProducer(String msg){
        rabbitTemplate.convertAndSend("deleteExchange","del",msg);
    }
}
